package com.atguigu.edu.publisher.service;

import com.atguigu.edu.publisher.beans.TradeSubjectOrderAmount;
import com.atguigu.edu.publisher.beans.TrafficChViewDate;
import com.atguigu.edu.publisher.beans.TrafficKeyWordDate;
import com.atguigu.edu.publisher.mapper.TradeStatsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

public interface TrafficStatsService {

    List<TrafficChViewDate> getChViewDate(String date);
    List<TrafficKeyWordDate> getKeyWordDate(String date);

    /**
     * 交易域统计Server接口
     */
    interface TradeStatsService {
        //获取某天总交易额
        BigDecimal getGMV(Integer date);
       //获取某天各科目下单总金额 取前10名
        List<TradeSubjectOrderAmount>getSubjectAmount(Integer date, Integer limit);
    }

    /**
     * 交易域统计server接口实现类
     */
    @Service
    class TradeStatsServiceImpl implements TradeStatsService {

        @Autowired
        private TradeStatsMapper tradeStatsMapper;


        @Override
        public BigDecimal getGMV(Integer date) {
            return tradeStatsMapper.selectGMV(date);
        }

        @Override
        public List<TradeSubjectOrderAmount> getSubjectAmount(Integer date,Integer limit) {
            return tradeStatsMapper.selectSubjectAmount(date,limit);
        }
    }
}
